package com.example.permission.common.page;

import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import java.io.Serializable;
import java.util.List;

/**
 * 分页返回
 *
 * @param <T>
 * @author xuwenqian
 */
@Data
public class Page<T> implements Serializable {
    private static final long serialVersionUID = 1L;
    @ApiModelProperty("第几页（默认1）")
    private int currentPage;
    @ApiModelProperty("页数")
    private int pageSize;
    @ApiModelProperty("总页数")
    private int totalPage;
    @ApiModelProperty("总数")
    private int totalCount;
    @ApiModelProperty("数据")
    private List<T> data;

    public Page(int currentPage, int pageSize, int totalCount, List<T> data) {
        this.currentPage = currentPage;
        this.pageSize = pageSize;
        this.totalPage = (totalCount + pageSize - 1) / pageSize;
        this.totalCount = totalCount;
        this.data = data;
    }

    public Page(int totalCount, List<T> data) {
        this.totalCount = totalCount;
        this.data = data;
    }
}
